<?php
  $yhendus=new mysqli("localhost", "if13", "ifikad", "if13_ehaverjo1");
  if(isSet($_REQUEST["uusleht"])){
    
    $kask->execute();
    header("Location: $_SERVER[PHP_SELF]");
    $yhendus->close();
    exit();
  }
  if(isSet($_REQUEST["kustutusid"])){
    $kask=$yhendus->prepare("DELETE FROM mikrobussivedu WHERE id=?");
    $kask->bind_param("i", $_REQUEST["kustutusid"]);
    $kask->execute();    
  }
?>

<!doctype html>
<html>
  <head>
    <title>Etteastete administreerimine</title>
    <style type="text/css">
       #menyykiht{
         float: left;
         padding-right: 30px;
       }
       #sisukiht{
         float:left;
       }
       #jalusekiht{
         clear: left;
       }
    </style>
  </head>
  <body>
    <div id="menyykiht">
        <h3>Halda soove:</h3>
        <ul>
          <?php
             $kask=$yhendus->prepare("SELECT id, kliendisoov FROM mikrobussivedu WHERE pakkuminekinnitatud=0");
             $kask->bind_result($id, $kliendisoov);
             $kask->execute();
             while($kask->fetch()){
			 
               echo "<li><a href='?id=$id'>".
                          htmlspecialchars($kliendisoov)."</a></li>";
             }
          ?>
		   
        </ul>

    </div>
    <div id="sisukiht">
       <?php
         if(isSet($_REQUEST["id"])){
            $kask=$yhendus->prepare("SELECT id, kliendisoov FROM mikrobussivedu
               WHERE id=? ");
            $kask->bind_param("i", $_REQUEST["id"]); 
            $kask->bind_result($id, $kliendisoov);
            $kask->execute();
            if($kask->fetch()){
			  echo "<h3>Muuda</h3>";
              echo htmlspecialchars($kliendisoov);
			  
			  echo "</br>";
              
              echo "<br /><a href='?kustutusid=$id'>kustuta</a>";
			  echo "<br /><a href='pakkumisetegemine.php?id=";
			  echo $id;
			  echo "'>tee pakkumine</a>";
            } else {
              echo "Vigased andmed.";
            }
         } 
         if(isSet($_REQUEST["lisamine"])){
           ?>
            
           <?php
         }
       ?>
    </div>
    <div id="jalusekiht">
     
    </div>
  </body>
</html>
<?php
  $yhendus->close();
?>